using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using DataLayer;
using InfraStructureLayer;
using DataAccessLayer;
using EntityLayer;

namespace BusinessLayer
{
    public class busSearch:BusinessBase
	{
        public busSearch()
            : base()
		{
		}


		public DataTable Search(entSearch parEntSearch)
		{
			try
			{
                DbConnector insDbConnector  = new DbConnector();
				datSearch insDatSearch = new datSearch();

                datSearchLogs insDatSearchLogs = new datSearchLogs();
                entSearchLogs insEntSearchLogs = new entSearchLogs();
                insEntSearchLogs.SearchLogText = parEntSearch.SearchText;
                insDatSearchLogs.InsertSearchLogs(insEntSearchLogs, insDbConnector);

                DataTable insDataTableSearch= insDatSearch.Search(parEntSearch,insDbConnector);
                insDataTableSearch.Columns.Add("RowNumber", typeof(int));
                int i=0;
                foreach (DataRow dr in insDataTableSearch.Rows)
                {
                    i++;
                    dr["RowNumber"] = i;
                }
                return insDataTableSearch;
			}
			catch (SFException ex)
			{
				this.ErrorMessage = ex.Message;
			}
			return null;
		}
	
	}
}
